package com.resume.aipeople.dto;

import lombok.Data;
import lombok.NoArgsConstructor;
import lombok.AllArgsConstructor;

import java.time.LocalDateTime;

@Data
@NoArgsConstructor
@AllArgsConstructor
public class ChatSessionDTO {
    
    private Long id;
    private String sessionId;
    private Long characterId;
    private String characterName;
    private String characterDescription;
    private String sessionTitle;
    private LocalDateTime createdAt;
    private LocalDateTime updatedAt;
    private LocalDateTime lastMessageAt;
    private Integer messageCount;
    private Boolean isActive;
    
    // 构造函数，从ChatSession实体转换
    public ChatSessionDTO(com.resume.aipeople.entity.ChatSession session) {
        this.id = session.getId();
        this.sessionId = session.getSessionId();
        this.sessionTitle = session.getSessionTitle();
        this.createdAt = session.getCreatedAt();
        this.updatedAt = session.getUpdatedAt();
        this.lastMessageAt = session.getLastMessageAt();
        this.messageCount = session.getMessageCount();
        this.isActive = session.getIsActive();
        
        // 安全地获取角色信息
        if (session.getCharacter() != null) {
            this.characterId = session.getCharacter().getId();
            this.characterName = session.getCharacter().getName();
            this.characterDescription = session.getCharacter().getDescription();
        }
    }
}
